package com.leyou.order.web;

import com.leyou.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/pay")
public class PayController {

    @Autowired
    private OrderService orderService;

    /**
     * 接收微信异步通知接口
     * @param data
     * @return
     */
    @PostMapping(value = "/notify",produces = "application/xml")
    public ResponseEntity<Map<String,String>> handlerNotify(
            @RequestBody Map<String,String> data
    ){
        System.out.println("微信通知来了---->data = " + data);
        //接收结果
        Map<String,String> msg = orderService.handlerNotify(data);
        return ResponseEntity.ok(msg);
    }

}
